<template>
    <el-row>
        <el-col :span="24">
            <el-card class="box-card">
                <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                    label-width="68px">
                    <el-form-item label="客户类型" prop="customerType">
                        <el-select v-model="queryParams.customerType" filterable placeholder="请选择" style="width: 150px">
                            <el-option v-for="dict in dict.type.customer_type" :key="dict.value" :label="dict.label"
                                :value="dict.value" />
                        </el-select>
                    </el-form-item>
                  <el-form-item label="客户编码" prop="customerCode">
                    <el-input v-model="queryParams.customerCode" placeholder="请输入客户编码" clearable style="width: 150px" />
                  </el-form-item>
                    <el-form-item label="客户名称" prop="customerName">
                        <el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable style="width: 150px" />
                    </el-form-item>
                    <el-form-item label="身份证号" prop="idNumber">
                        <el-input v-model="queryParams.idNumber" placeholder="请输入身份证号" clearable style="width: 150px" />
                    </el-form-item>
                    <el-form-item label="开户时间" prop="openDate">
                        <el-date-picker type="date" placeholder="选择开户时间" v-model="queryParams.openDate" style="width: 150px"
                            value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="手机号" prop="telephone">
                        <el-input v-model="queryParams.telephone" placeholder="请输入手机号" clearable style="width: 150px" />
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                    </el-form-item>
                </el-form>
                <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">
                        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                            v-hasPermi="['system:changemeter:add']">新增</el-button>
                    </el-col>

                    <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
                </el-row>
                <el-table v-loading="loading" :data="userList" border>
                  <el-table-column label="客户编码" align="center" key="customerCode" prop="customerCode"
                                   :show-overflow-tooltip="true" />
                    <el-table-column label="客户名称" align="center" key="customerName" prop="customerName"
                        :show-overflow-tooltip="true" />
                    <el-table-column prop="status" label="客户类型" width="80">
                        <template slot-scope="scope">
                            <dict-tag :options="dict.type.customer_type" :value="scope.row.customerType" />
                        </template>
                    </el-table-column>
                    <el-table-column label="地址" align="center" key="address" prop="address" :show-overflow-tooltip="true" />
                    <el-table-column label="旧表号" align="center" key="oldMeterCode" prop="oldMeterCode"
                                     :show-overflow-tooltip="true" />
                    <el-table-column label="新表号" align="center" key="newMeterCode" prop="newMeterCode"
                                     :show-overflow-tooltip="true" />
                    <el-table-column label="旧卡号" align="center" key="oldCardNumber" prop="oldCardNumber"
                                     :show-overflow-tooltip="true" />
                    <el-table-column label="新卡号" align="center" key="newCardNumber" prop="newCardNumber"
                                     :show-overflow-tooltip="true" />
                    <el-table-column label="旧气表厂家" align="center" key="oldManufacturer" prop="oldManufacturer"
                                     :show-overflow-tooltip="true" width="120" />
                    <el-table-column label="新气表厂家" align="center" key="newMeterManufacturerName" prop="newMeterManufacturerName"
                                   :show-overflow-tooltip="true" width="120" />
                    <el-table-column label="旧气表类型" align="center" key="oldMeterTypeName" prop="oldMeterTypeName"
                                   :show-overflow-tooltip="true" width="120" />
                    <el-table-column label="新气表类型" align="center" key="newMeterType" prop="newMeterType"
                                     :show-overflow-tooltip="true" width="120" />
                    <el-table-column label="补气量" align="center" key="supplementGasVolume" prop="supplementGasVolume"
                        :show-overflow-tooltip="true" />
                    <el-table-column label="补气金额" align="center" key="supplementAmount" prop="supplementAmount"
                        :show-overflow-tooltip="true" />
                    <el-table-column label="超用气量" align="center" key="beyondGasVolume" prop="beyondGasVolume"
                        :show-overflow-tooltip="true" />
                    <el-table-column label="超用金额" align="center" key="beyondGasAmount" prop="beyondGasAmount"
                        :show-overflow-tooltip="true" />
                    <el-table-column label="换表日期" align="center" key="changeDate" prop="changeDate"
                        :show-overflow-tooltip="true" width="100" />
<!--                    <el-table-column label="旧表底数" align="center" key="oldBaseNumber" prop="oldBaseNumber"-->
<!--                        :show-overflow-tooltip="true" />-->
<!--                    <el-table-column label="新表底数" align="center" key="newBaseNumber" prop="newBaseNumber"-->
<!--                                   :show-overflow-tooltip="true" />-->
                    <el-table-column label="换表操作类型" align="center" key="changeType" prop="changeType"
                        :show-overflow-tooltip="true" width="120" />
                    <el-table-column label="支付类型" align="center" key="paymentType" prop="paymentType"
                        :show-overflow-tooltip="true" >
                        <template slot-scope="scope">
                            <span v-if="scope.paymentType==1">现金支付</span>
                            <span v-if="scope.paymentType==2">扫码支付</span>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column label="营业点" align="center" key="stationId" prop="stationId"
                        :show-overflow-tooltip="true" /> -->
<!--                    <el-table-column label="图片路径" align="center" key="attachment" prop="attachment"-->
<!--                        :show-overflow-tooltip="true" >-->
<!--                        <template slot-scope="scope">-->
<!--                            <el-image-->
<!--                                style="width: 100px; height: 100px"-->
<!--                                :src="scope.attachment"-->
<!--                                >-->
<!--                            </el-image>-->
<!--                        </template>-->
<!--                    </el-table-column>-->
		    <el-table-column label="备注" align="center" key="remark" prop="remark" :show-overflow-tooltip="true" />
                    <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
                        <template slot-scope="scope">
                            <el-button size="mini" type="text"  @click="handleSee(scope.row)"
                            v-hasPermi="['system:changemeter:query']">查看</el-button>
                        </template>
                    </el-table-column>
                </el-table>

                <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize" @pagination="getList" />
            </el-card>
        </el-col>
        <el-dialog title="新增换表记录" :visible.sync="open" width="1500px" append-to-body>
            <changeMeterAdd @closeDialog="closeDialog" />
        </el-dialog>
        <el-dialog title="详情" :visible.sync="open1" width="1500px" append-to-body>
            <changeMeterSee @closeDialog="closeDialog1" :id = custemerId />
        </el-dialog>
    </el-row>
</template> 
<script>
import { changemeterList, } from "@/api/fileManagement/changeMeter.js"
import changeMeterAdd from './changeMeterAdd.vue'
import changeMeterSee from './ChangeMeterSee.vue'
export default {
    dicts: ["customer_type"],
    data() {
        return {
            open: false,
            open1:false,
            userList: [],
            size: 'mini',
            // 显示搜索条件
            showSearch: true,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                customerType: null,
                customerName: null,
                idNumber: null,
                deptId: null,
                openDate: null,
                telephone: null,
                customerCode: null
            },
            total: 0,
            custemerId:''

        }
    },
    components: { changeMeterAdd,changeMeterSee },
    created() {
        this.getList();
    },
    methods: {
        handleSee(row){
            this.custemerId = row.id;
            this.open1 =true
        },
        // 关闭弹框
        closeDialog() {
            this.open = false
        },
        closeDialog1(){
            this.open1 =false
        },
        // 新增
        handleAdd() {
            this.open = true
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        getList() {
            this.loading = true;
            changemeterList(this.queryParams).then((response) => {
                this.userList = response.rows;
                this.total = response.total;
                this.loading = false;
                // let list = JSON.parse(JSON.stringify(response.rows))
                // list.map((res) => {
                //   this.meterList.map((item) => {
                //     if (res.meterType == item.id) {
                //       res.meterType = item.typeName
                //     }
                //   });
                // });
            });
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
    },


}
</script>